/*
* Copyright 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
*/
package com.laihuichuxing.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 *
 * @author: Qinxuefeng
 * @since: 1.0
 * Create Date Time: 2018/12/26 16:47
 * Update Date Time:
 */

public abstract class Subject {
    public List<Observer> observers = new ArrayList<>();
    public void attach(Observer observer){observers.add(observer);}
    public void detach(Observer observer){observers.remove(observer);}
    public void notifyObserver(){
        for (Observer observer:observers){
            observer.update();
        }
    }
}
